Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added length for Set, IntSet and HashTable #454

Closed
wants to merge 1 commit into from
Closed

Added length for Set, IntSet and HashTable #454

wants to merge 1 commit into from

Conversation

friggeri
Copy link

The absence of length for those types caused errors when using comprehensions such as :

h = {1=>1, 2=>2}
[k | (k,v) = h]

@JeffBezanson
Copy link
Member

The idea was to use length for ordered collections and numel otherwise, but maybe this is pointless. It looks like we should only have length and at most make numel an alias. @StefanKarpinski @ViralBShah what do you guys think?

@friggeri
Copy link
Author

I understand the idea behind this, but then it makes it impossible to write a comprehension with an unordered collection. As a prior, Python uses len to return the number of elements in sets and hashtables as well as in lists.

JeffBezanson added a commit that referenced this pull request Feb 24, 2012
@JeffBezanson
Copy link
Member

I'll close this since I decided to take this suggestion even farther, and simplify things by only using length.

@friggeri
Copy link
Author

Great, thanks !

@StefanKarpinski
Copy link
Member

For the record, I retroactively concur.

KristofferC pushed a commit that referenced this pull request Jul 3, 2018
dependencis -> dependencies
NHDaly added a commit to NHDaly/julia that referenced this pull request Dec 18, 2019
…uate arguments immediately.

Add the ability to evaluate some parts of a `@spawn`/`@async`
immediately, in the current thread context.

This prevents variables being "boxed" in order to capture them in the
closure, exactly the same as wrapping them in a let-block locally.

For example, `$x` expands like this:
```julia
julia> @macroexpand @async $x + 2
quote
    #= task.jl:361 =#
    let var"#JuliaLang#454" = x
        #= task.jl:362 =#
        local var"JuliaLang#9#task" = Base.Task((()->begin
                            #= task.jl:358 =#
                            var"#JuliaLang#454" + 2
                        end))
        #= task.jl:363 =#
        if $(Expr(:islocal, Symbol("##sync#95")))
            #= task.jl:364 =#
            Base.push!(var"##sync#95", var"JuliaLang#9#task")
        end
        #= task.jl:366 =#
        Base.schedule(var"JuliaLang#9#task")
        #= task.jl:367 =#
        var"JuliaLang#9#task"
    end
end
```
JeffBezanson pushed a commit that referenced this pull request Dec 18, 2019
…immediately (#33119)

Adds $-interpolation syntax to `@async` and `Threads.@spawn`, to evaluate arguments immediately.

Add the ability to evaluate some parts of a `@spawn`/`@async`
immediately, in the current thread context.

This prevents variables being "boxed" in order to capture them in the
closure, exactly the same as wrapping them in a let-block locally.

For example, `$x` expands like this:
```julia
julia> @macroexpand @async $x + 2
quote
    #= task.jl:361 =#
    let var"##454" = x
        #= task.jl:362 =#
        local var"#9#task" = Base.Task((()->begin
                            #= task.jl:358 =#
                            var"##454" + 2
                        end))
        #= task.jl:363 =#
        if $(Expr(:islocal, Symbol("##sync#95")))
            #= task.jl:364 =#
            Base.push!(var"##sync#95", var"#9#task")
        end
        #= task.jl:366 =#
        Base.schedule(var"#9#task")
        #= task.jl:367 =#
        var"#9#task"
    end
end
```
KristofferC pushed a commit that referenced this pull request Apr 11, 2020
…immediately (#33119)

Adds $-interpolation syntax to `@async` and `Threads.@spawn`, to evaluate arguments immediately.

Add the ability to evaluate some parts of a `@spawn`/`@async`
immediately, in the current thread context.

This prevents variables being "boxed" in order to capture them in the
closure, exactly the same as wrapping them in a let-block locally.

For example, `$x` expands like this:
```julia
julia> @macroexpand @async $x + 2
quote
    #= task.jl:361 =#
    let var"##454" = x
        #= task.jl:362 =#
        local var"#9#task" = Base.Task((()->begin
                            #= task.jl:358 =#
                            var"##454" + 2
                        end))
        #= task.jl:363 =#
        if $(Expr(:islocal, Symbol("##sync#95")))
            #= task.jl:364 =#
            Base.push!(var"##sync#95", var"#9#task")
        end
        #= task.jl:366 =#
        Base.schedule(var"#9#task")
        #= task.jl:367 =#
        var"#9#task"
    end
end
```
cmcaine pushed a commit to cmcaine/julia that referenced this pull request Nov 11, 2022
Keno pushed a commit that referenced this pull request Oct 9, 2023
This supports SSAValue args for cglobal while also fixing a bug
in which a GotoIfNot ended up going to the wrong statement.
The latter was a consequence of incorrect :call unnesting.

Fixes #455
Fixes #454
Fixes #415
Fixes JuliaDebug/Debugger.jl#275
Improves #354
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants